/* eslint-disable @typescript-eslint/no-explicit-any */
import { PropType } from 'vue';
import { RequiredProp } from '../common';

/**
 * 获取编辑器通用props
 *
 * @export
 * @template C
 * @return {*} 
 */
export function getEditorProps<C>() {
  return {
    value: String,
    controller: new RequiredProp(Object as PropType<C>),
    data: new RequiredProp(Object as PropType<IData>),
    disabled: {
      type: Boolean,
    },
    readonly: {
      type: Boolean,
      default: false,
    },
    autoFocus: {
      type: Boolean,
      default: false,
    },
    overflowMode: { type: String },
    controlParams: {
      type: Object,
      required: false,
    },
  };
}

/**
 * 获取编辑器通用emits
 *
 * @export
 * @template V
 * @return {*} 
 */
export function getEditorEmits<V>() {
  return {
    /** 值变更事件 */
    change: (_value: V, _name?: string) => true,
    /** 失焦事件 */
    blur: (_event?: IData) => true,
    /** 聚焦事件 */
    focus: (_event?: IData) => true,
    /** 回车事件 */
    enter: (_event?: IData) => true,
    /** 信息文本变更事件 */
    infoTextChange: (_text: string) => true,
  };
}

/**
 * 获取表格列编辑器通用emits
 *
 * @export
 * @template V
 * @return {*} 
 */
export function getGridEditorEmits<V>() {
  return {
    /** 值变更事件 */
    change: (_value: V, _name?: string) => true,
    /** 是否正在操作事件 */
    rowSave: () => true,
  };
}

/**
 * 表格编辑器通用props
 *
 * @export
 * @return {*} 
 */
export function getGridEditorCommonProps() {
  return {
    hasError: {
      type: Boolean,
    },
  };
}
